package de.g18.treggr.server;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class TreggrServer {

	private final ServerSocket server;

	public TreggrServer(int port) throws IOException {
		server = new ServerSocket(port);
	}

	/**
	 * Startet den Server. Er wartet auf Verbindungen
	 */
	public void startServing() {
		while (true) {
			Socket client = null;
			try {
				System.out.println("Warte...");
				client = server.accept();
				System.out.println("Verbindung hergestellt...");
				new ServerThread(client).start();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}